
import env from '../config/env';
const jwt = require('jsonwebtoken');
//权限
class AuthService{
    async authUser(authorization: string){
        let authtoken = authorization.substr("Bearer ".length);
        let auth: AuthUser = jwt.decode(authtoken, env.corpsecret);
        if (!auth) {
            throw '对不起，您无权限访问！';
        }
        return auth;
    }
}

interface AuthUser {
    userId: string;
    is_sys: boolean;
    jobnumber: string;
    name: string;
}
let authService = new AuthService();
export default authService;